var PersonnelManager = function(){
	return {
		init : function(callback){
			this.search(function(data){
				//var users = [""];
				//if(data.length != 0){
					$("#personnel-modal").modal("show");
					$('#save-personnel-btn').on('click', function(){
						var users = $('#personnel-select').val();
						if(users == ""){
							BootstrapDialog.show({
								title : messages.public_cue_message,
								message : data.message,
								buttons : [ {
									label : "请选择下一审批人",
									action : function(dialog) {
										dialog.close();
									}
								} ]
							});
						}else{
							callback(users);
						}
						$("#personnel-modal").modal("hide");
					});
				//}else{
				//	callback(users);
				//}
			});
		},
		search : function(callback){
			$.post( ctx + "/user/getParentGroupAndUsers?now=" + new Date().getTime(), function(data){
				$('#personnel-select').empty().siblings('.tree-multiselect').remove();
				for(var i in data){
					$('#personnel-select').append("<option value='"+data[i].user.id+"' data-section='"+data[i].group.name+"'>"+data[i].user.userName+"</option>");
				}
				$('#personnel-select').treeMultiselect({ searchable: true, enableSelectAll: true, sortable: true, selectAllText:"全选", unselectAllText:"全不选" });
				callback(data);
			});
		}
	}
}()